#ifndef __SUBSYSTEM_SIGN_BLOCK_BEHAVIOR_H__
#define __SUBSYSTEM_SIGN_BLOCK_BEHAVIOR_H__

#include "SubsystemBlockBehavior.hpp"
#include <map>
#include "Game/SignTextData.hpp"
#include <mutex>

namespace PocketSurvival
{
    class SubsystemTerrain;

    class SubsystemSignBlockBehavior : public SubsystemBlockBehavior
    {
    protected:
        std::mutex m_signTextMapMutex;
        std::map<Point3, SignTextData> m_signTextByPointMap;

        SubsystemTerrain *m_terrain;

    public:
        virtual void onBlockRemoved(int32_t value, int32_t newValue, int32_t x, int32_t y, int32_t z) override;
        virtual void onNeighborBlockChanged(int32_t x, int32_t y, int32_t z, int32_t neighborX, int32_t neighborY, int32_t neighborZ) override;
        virtual bool onInteract(const TerrainRaycastResult &raycastResult, ComponentMiner *componentMiner) override;

        void setSignData(const SignTextData& signTextData);
        bool getSignData(const Point3 &point, SignTextData &signTextData);

    public:
        SubsystemSignBlockBehavior();

        virtual void load(const nlohmann::json& json) override;
        virtual void save(nlohmann::json& json) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;

        virtual const std::string& getName() const override;
    };
}

#endif